import type FormItem from "@/components/form/type/FormItem.ts";
import type TableColumn from "@/components/table/type/TableColumn.ts";

const useSchema = () => {
    /**
     * 查询条件表单结构数据
     */
    const searchSchema: FormItem[] = [
        {row: 0, span: 4, label: "用户名", key: "userName", type: "input", attr: {clearable: true}},
        {row: 0, span: 4, label: "姓名", key: "realName", type: "input", attr: {clearable: true}},
        {row: 0, span: 4, label: "手机号", key: "phone", type: "input", attr: {clearable: true}},
        {row: 0, span: 4, label: "操作", key: "operate", type: "slot"},
    ]

    /**
     * 表格结构数据
     */
    const tableColumns: TableColumn[] = [
        {key: 'id', title: '序号', width: 80, align: 'center', type: 'index'},
        {key: 'userName', title: '用户名', align: 'center'},
        {key: 'realName', title: '真实姓名', align: 'center'},
        {key: 'avatar', title: '头像', align: 'center', type: 'image'},
        {key: 'phone', title: '手机号码', align: 'center'},
        {key: 'email', title: '邮箱', align: 'center', type: 'string'},
        {key: 'birthday', title: '生日', align: 'center'},
        {key: 'idCard', title: '证件号码', align: 'center'},
        {key: 'remark', title: '备注', align: 'center', type: 'string'},
        {key: 'status', title: '状态', align: 'center', type: 'slot'},
        {key: 'operate', title: '操作', width: 170, type: 'slot', align: 'center'},
    ]

    /**
     * dialog结构数据
     */
    const dialogScheme: FormItem[] = [
        {
            row: 0,
            span: 12,
            label: "用户名",
            key: "userName",
            placeholder: "用户名",
            type: "input",
            required: true,
            useRules: ['alphaNumChinese']
        },
        {row: 0, span: 12, rowSpan: 3, label: "头　像", key: "avatar", placeholder: "头　像", type: "slot"},
        {
            row: 1,
            span: 12,
            label: "姓　名",
            key: "realName",
            placeholder: "姓名",
            type: "input",
            required: true,
            useRules: ['chinese']
        },
        {
            row: 2,
            span: 12,
            label: "手机号",
            key: "phone",
            placeholder: "手机号",
            type: "input",
            required: true,
            useRules: ['phone']
        },
        {row: 3, span: 12, label: "邮　件", key: "email", placeholder: "邮件", type: "input"},
        {row: 3, span: 12, label: "证件号", key: "idCard", placeholder: "证件号", type: "input"},
        {row: 4, span: 12, label: "部　门", key: "depart", type: "slot"},
        {
            row: 4,
            span: 12,
            label: "状　态",
            key: "status_bool",
            type: "switch",
            attr: {activeText: "启用", inactiveText: "禁用"}
        },
        {row: 5, span: 24, label: "备　注", key: "remark", placeholder: "备注", type: "textarea"},
    ]

    /**
     * drawer结构数据
     */
    const drawerScheme: FormItem[] = [
        {row: 0, span: 24, label: "用户名", key: "userName", placeholder: "用户名", type: "input", required: true},
        {row: 1, span: 24, label: "姓　名", key: "realName", placeholder: "姓名", type: "input", required: true},
        {
            row: 2,
            span: 24,
            label: "手机号",
            key: "phone",
            placeholder: "手机号",
            type: "input",
            required: true,
            useRules: ['phone']
        },
        {row: 3, span: 24, label: "邮　件", key: "email", placeholder: "邮件", type: "input"},
        {row: 4, span: 24, label: "证件号", key: "idCard", placeholder: "证件号", type: "input"},
        {row: 5, span: 24, label: "部　门", key: "depart", placeholder: "部门", type: "slot"},
        {
            row: 6,
            span: 24,
            label: "状　态",
            key: "status_bool",
            type: "switch",
            attr: {activeText: "启用", inactiveText: "禁用"}
        },
        {row: 7, span: 24, label: "备　注", key: "remark", placeholder: "备注", type: "textarea"},
    ]

    const userRoleSearchScheme: FormItem[] = [
        {row: 0, span: 5, label: "角色名称", key: "roleName", placeholder: "角色名称", type: "input"},
        {row: 0, span: 5, label: "角色编码", key: "roleCode", placeholder: "角色编码", type: "input"},
        {row: 0, span: 7, label: "部门", key: "depart", placeholder: "部门", type: "slot"},
        {row: 0, span: 6, offset: 1, label: "搜索", key: "operate", type: "slot"},
    ]

    const userRoleTableScheme: TableColumn[] = [
        {key: 'id', title: '序号', width: 80, align: 'center', type: 'index'},
        {key: 'roleName', title: '角色名称', align: 'center', type: 'string'},
        {key: 'roleCode', title: '角色编码', align: 'center', type: 'string'},
        {key: "roleType", title: "角色类型", width: 150, align: "center", type: "slot"},
        {key: 'departName', title: '角色部门', align: 'center', type: 'string'},
        {key: 'status', title: '拥有状态', align: 'center', type: 'slot'},
    ]

    /**
     * 回收站表格结构数据
     */
    const recycleBinTableColumns: TableColumn[] = [
        {key: 'id', title: '主键id', width: 80, align: 'center'},
        {key: 'userName', title: '用户名', align: 'center'},
        {key: 'realName', title: '真实姓名', align: 'center'},
        {key: 'avatar', title: '头像', align: 'center', type: 'image'},
        {key: 'phone', title: '手机号码', align: 'center'},
        {key: 'email', title: '邮箱', align: 'center', type: 'string'},
        {key: 'birthday', title: '生日', align: 'center'},
        {key: 'idCard', title: '证件号码', align: 'center'},
        {key: 'remark', title: '备注', align: 'center', type: 'string'},
        {key: 'status', title: '状态', align: 'center'},
        {key: 'operate', title: '操作', width: 120, type: 'slot', align: 'center', fixed: 'right'},
    ]

    return {
        searchSchema,
        tableColumns,
        dialogScheme,
        drawerScheme,
        userRoleSearchScheme,
        userRoleTableScheme,
        recycleBinTableColumns
    }
}

export default useSchema